home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 December / macformat-031.iso / mac / Internet / HTML Software / BBEdit HTML Tools v1.3.1 / Documentation / User's Markup Info.txt < prev   
Encoding:
Text File  |  1995-03-06  |  14.7 KB  |  402 lines  |  [TEXT/R*ch]

  1. User's Markup Tool - part of the BBEdit HTML Tools package.
  2. ©1994 Lindsay Davies
  3. email: Lindsay.Davies@sheffield.ac.uk
  4.  
  5.  
  6. Status:                Semi-informal release pending feedback :-)
  7. Last updated:        22 Aug 1994
  8.             
  9.  
  10.  
  11. USER DEFINED MARKUP ROUTINES
  12. -------------------------------------------------------------------------
  13.  
  14. This tool will help those people who regularly have to edit HTML
  15. documents. It allows you to define up to 10 'styles' that can be applied
  16. to any part of your text.
  17.  
  18. (Background note: This tool started off with a rather more limited
  19. scope in mind. It seems that in developing it, it has changed from being
  20. a tool for storing simple markup styles to a simple macro package. So bear
  21. in mind that macros weren't its original objective, and forgive its
  22. rather clumsy design!).
  23.  
  24.  
  25.  
  26.  
  27. Introduction:
  28. -------------------------------------------------------------------------
  29.  
  30. To define your style, bring up the 'User Styles' tool, and you will see a
  31. number of undefined buttons. To create a label and definition for your
  32. style, simply click on a button and fill out the 'Label' and 'Definition'
  33. fields (The definition field isn't yet labelled).
  34.  
  35. The best way to introduce the tool is with a worked through example.
  36. Suppose that we have a style for certain section headings that requires
  37. marking up like this:
  38.  
  39.    <H2><I>My Heading</I></H2>
  40.    <HR>
  41.  
  42. This would normally involve 4 operations (one for each of the
  43. tags involved, and one for the return before the <HR> tag).
  44.  
  45. To define your own style to do this automatically, Make your definition
  46. as follows:
  47.  
  48.    <H2><I>…</I></H2>\r<HR>
  49.    
  50. Working through this example we have the opening Heading tag,
  51. the opening Italic tag, and then we have the important part, the
  52. ellipsis. You type the ellipsis by using Option-; not by typing 3
  53. periods. The ellipsis is the character that represents your current
  54. selection. All text before the ellipsis goes before your selection, and
  55. of course, everything after the ellipsis follows after the current
  56. selection.
  57.  
  58. So after the ellipsis we have the closing Italic and Heading tags.
  59. Following on from this is \r which represents a return character.
  60. Finally we have the horizontal rule tag.
  61.  
  62. So if you select your text, eg
  63.  
  64.     My Heading
  65.     
  66. ...and then apply this style to it, it will be marked up exactly as the
  67. first example was, but in one operation.
  68.  
  69. If you have number of headings to mark up, then you won't want to keep
  70. having the dialog box keep appearing. This is where the checkbox in the
  71. bottom left of the dialog comes in. Check this if you want the
  72. currently selected style to be applied when choose the 'User Styles' tool
  73. from the menu WITHOUT the dialog appearing. To bring the dialog
  74. back, hold the CONTROL key down while selecting the tool.
  75.  
  76. This is useful if you assign a command-key to the tool (using the
  77. excellent BBXKeys extension (from Sumex), or with the commercial version
  78. of BBEdit). You can then just use command-<whatever key you want> to
  79. markup the current selection with your chosen style.
  80.  
  81. OK, that's the basics. If you don't want to know any more, then save the
  82. next bit till later! You may however wish to have a look at the examples
  83. at the end of this document, which will give you an idea of the sorts of
  84. things that you can do.
  85.  
  86.  
  87.  
  88. Intermediate Stuff:
  89. -------------------------------------------------------------------------
  90. In your style definition, you can put in certain placeholders. You have
  91. already met the one for a return - \r. There are some others available to
  92. help you with your creative impluses:
  93.  
  94.   Placeholder             Function
  95.      \r                    Inserts return character
  96.      \t                    Inserts tab character
  97.      \c                    Inserts clipboard (eg whatever has been
  98.                              most recently copied or cut.
  99.      \b                    Inserts the contents of the buffer
  100.      \…                    Inserts an ellipsis
  101.      \\                    Inserts a slash
  102.      \!                    Inserts an exclamation mark
  103.      \"                    Inserts a quote
  104.      \s                    Inserts the current selection
  105.      \d                    Inserts the current date (short format)
  106.      \D                    Inserts the current date (long format)
  107.  
  108.  
  109. So far so simple (?). Now for some more stuff...
  110.  
  111.  
  112.  
  113. Slightly More Difficult Stuff:
  114. -------------------------------------------------------------------------
  115. I guess I'm lazy, but I thought I'd add a few extra things to help me
  116. when I am marking up. So the next thing to learn about are the 'commands'
  117. that you can insert into your style definition.
  118.  
  119. The commands simply allow you to manipulate and edit the current
  120. selection. Stringing a series of commands together can allow you to
  121. perform quite complex tasks.
  122.  
  123. Again, we'll work through an example. The previous example relied
  124. upon you selecting the text to be marked up. Much easier would be to
  125. simply click in the text, and have your definition automatically select
  126. the text for you.
  127.  
  128. So, referring back to the previous example, if we clicked in the middle
  129. of the word 'heading', we might want to select the whole line before
  130. applying the markup to it.
  131.  
  132. This is done using the command "!SL" (without the quotes). This reads as
  133.  
  134.         !    <--    The next 2 characters represent a command and parameter
  135.         S     <--    'Select' command
  136.         L    <--    This parameter means select the current line.
  137.         
  138. So the new definition would be:
  139.  
  140.    !SL<H2><I>...</I></H2>\r<HR>
  141.  
  142. Which reads as 'select the line, insert the '<H2><I>' bits before
  143. the current selection, and insert  '</I></H2>' and a return character and
  144. '<HR>' after the selection. (Hopefully you are still with me - there's more!).
  145.  
  146. List of Commands:
  147.  
  148. Command            Function
  149. =======         ========
  150. Selecting
  151.     !SW            select the word that the insertion point is in
  152.     !SL            select the line that the insertion point is in
  153.     !SP            select the paragraph that the insertion point is in
  154.     !SD            select the whole document.
  155.     !SC            select all text and tags of a Container.
  156.     !ST            select all Text within a container.
  157.     
  158.  
  159. Copying
  160.     !CC            copy the current selection to the clipboard
  161.     !CB            copy the current selection to the Buffer.
  162.     !CA            append the current selection to the clipboard
  163.     !CT"xyz"    append the text 'xyz' to the clipboard (all the placeholders
  164.                 mentioned above can be used in this string).
  165.     !CZ            clear the clipboard
  166.  
  167. Extending
  168.     !EF"xyz"    extends the selection forwards to start of string "xyz"
  169.     !E^            extend to start of line
  170.     !E$            extend to end of line
  171.  
  172. Inserting
  173.     !IS"xyz"    insert text "xyz" at start of selection
  174.     !IE"xyz"    insert text "xyz" at end of selection
  175.     !IR"xyz"    insert "xyz" Replacing the selection
  176.  
  177. Finding
  178.     !FN"abc"    find next occurrence of "abc" where "abc" can include the
  179.                 simple grep patterns...
  180.                 '.'     matches any character
  181.                 '#'     matches any numeric character
  182.                 '.*'     matches zero or more characters (Note that although standard
  183.                         Grep is limited to a single line, in this case the pattern can
  184.                         span the entire document.
  185.                 '#*'    match zero or more numeric characters
  186.                 '#+'    match one or more numeric characters
  187.                 
  188.     !FA"abc"    same as above, but will find all matches of "abc" in the
  189.                 document.
  190.                      
  191. Place Insertion Point
  192.     !@E            insertion point at end of selection
  193.     !@S            insertion point at start of selection
  194.     !@T            insertion point at top of document
  195.     !@B            insertion point at bottom of document
  196.     !@L            insertion point at next line
  197.     !@P            insertion point at next paragraph
  198.     !@^            insertion point at start of line
  199.     !@$            insertion point at end of line
  200.     
  201. Case
  202.     !KR            raise the case of the selection
  203.     !KL            lower the case of the selection
  204.     !KT            make all HTML tags upper case
  205.  
  206. Deleting
  207.     !DS            delete the current selection
  208.     !DX            delete current selection + surrounding space
  209.     !DC            delete the clipboard
  210.     
  211. Misc
  212.     !Nx            set the next default definition to the number x (0 - 9)
  213.                 specified.
  214.     !|x            Run macro x after the current one has completed.
  215.     !BP            Beep - useful in some cases when you are debugging a macro.
  216.     !§k            Switch searching case sensitivity ON
  217.     !§K            Switch searching case sensitivity OFF (Default)
  218.  
  219. Note that you can use Command-. to exit from any series of commands
  220. you may be using.
  221.  
  222. *    Commands may have a single space between them to aid legibility.
  223.  
  224. *    The sequence of commands is limited to 255 characters in length.
  225.  
  226. A good example is having a list of delegate names for a conference. I
  227. want to have a main document with all the names, but have links from the
  228. names to vanity pages for each of them. In addition, I would like the
  229. names to be anchors. The names of the vanity pages are all in the format
  230. surname.html in a directory called 'vanity', and using the surname for
  231. the anchor name. eg:
  232.  
  233. Before:                After:
  234.  
  235. Joe Bloggs            <A NAME="Bloggs" HREF="/vanity/Bloggs.html">Joe Bloggs</A>
  236. University of X        University of X
  237. email: user@host    email: user@host
  238.  
  239.  
  240. This would normally require a fair bit of mouse and keyboard work to do,
  241. especially for a ist of 30 or so delegates. Better still would be to
  242. create a style definition that would do it all for me. eg:
  243.  
  244.     !SW!CC!SL!IS"<A NAME=\"\c\" HREF=\"/vanity/\c.html\">"!IE"</A>"
  245.     
  246. Assuming that I have clicked anywhere in the surname (ie 'Bloggs'),
  247. this definition reads as:
  248.  
  249.     !SW                    Select the Word (ie 'Bloggs')
  250.     !CC                    Copy the selection
  251.     !SL                    Select the Line.
  252.     !IS"<A NAME=\"        insert this text before the selection (note '\"' is
  253.                         required to enter a quote.)
  254.     \c                    insert the clipboard (ie 'Bloggs)
  255.     \" HREF=\"/vanity/    insert this text
  256.     \c                    again, insert the clipbaord
  257.     .html\">"            insert this text
  258.     !IE"</A>"            and insert this text after the selection to finish off.
  259.  
  260.  
  261. So, it doesn't look pretty, but it can be quite useful. If you want
  262. anything more powerful, then you really need to get stuck into GREP or
  263. PERL.
  264.  
  265. To recognise that you sometimes want to follow one style with
  266. another, you can tell your definition which definition to use next.
  267.  
  268. Using the above example, I could have the definition just described to
  269. mark up the name. I might then wish to have another definition to mark up
  270. the email address. By adding !N2 in front of the first definition, the
  271. next time the tool is used, definition 2 will be the default. (and if
  272. _that_ definition includes a !N1, then repeated use of the tool will
  273. cycle through these definitions 1 and 2.)
  274.  
  275.  
  276. Obfuscation time...
  277. -------------------------------------------------------------------------
  278.  
  279. There will be occasions when you want to perform a series of tasks. You
  280. could allocate them all to different macros, but if they are all meant to
  281. work together, this would be a waste of space.
  282.  
  283. You can therefore string together seqences of commands into segments
  284. within a definition. To delineate a segment, type a bullet. You will see
  285. that the next segment will start on a new line, and be prefixed by a bullet.
  286.  
  287. A simple example of this in use would be the situation where you wanted
  288. to compile a list of all anchors in your document. The list will be
  289. compiled on the clipboard, so the first thing you would need to do is to
  290. clear it of any current text.
  291.  
  292. You will then want to find all anchors, so search for all text starting
  293. with "<A " and ending with "</A>". If it is found, it will be selected,
  294. and we want to append the selection and a return (so that all anchors
  295. start on a new line) to the clipboard. You then need to move the
  296. insertion point to the end of the selection so that the next iteration
  297. won't simply select the same part again. Just to illustrate the point
  298. further, when this second sequence has finished, we want to beep to
  299. signify that we have come to the end.
  300.  
  301. The macro itself...
  302.  
  303.         !DC
  304.         •!FA"<A .*</A>" !CT"\s\r"!@E
  305.         •!BP
  306.  
  307. Note that there are three segments here - the first one that deletes the
  308. clipboard only wants to be performed once. The newline and bullet
  309. delineate the second segment, which iterates through the document
  310. finding and appending the data to the clipboard. Only when this has
  311. complete will the third segment be invoked, and the machine will beep.
  312.  
  313.  
  314. Examples
  315. -------------------------------------------------------------------------
  316.  
  317. Well, that's probably clear as mud, so here are some examples:
  318.  
  319.  
  320. -------------------------------------------------------------------------
  321. •  To embolden a word (just click anywhere in the word you want to
  322.    embolden)
  323.  
  324.     !SW !IS"<B>" !IE"</B>"        Select the word, insert <B> at the start of the
  325.                                 selection, insert </B> at the end of the selection.
  326.                     
  327. -------------------------------------------------------------------------
  328. •  To embolden a line:
  329.  
  330.     !SL !IS"<B>" !IE"</B>"        Exactly the same, but we use !SL instead of !SW.
  331.                     
  332. -------------------------------------------------------------------------        
  333. •  To add paragraph tags to a paragraph:
  334.  
  335.     !SP !IS"<P>" !IE"</P>"            Select paragraph, insert <P> at the end of the selection.
  336.     
  337. -------------------------------------------------------------------------
  338. •  To make a word into a named anchor:
  339.  
  340.     !SW !CC !IS"<A NAME="\c">" !IE"</A>"
  341.     
  342.     Select the word, copy it, insert the tag, inserting the clipboard between the quotes,
  343.     and inserting the closing tag at the end of the selection.
  344.  
  345. -------------------------------------------------------------------------
  346. •  To remove the current tags from around some text:
  347.  
  348.     !ST !CC !SC !IR"\c"        Select text up to tags, copy it, select containing tags
  349.                             as     well, insert replacing the selection with what was
  350.                             just copied.
  351.     
  352. -------------------------------------------------------------------------
  353. •  To mark up glossary items (which are on consecutive lines):
  354.  
  355.         !SL !IS"<DT>" !FN"\r" !@E !IS"<DD>"
  356.         
  357.         Select line, Insert "<DT>" at the start of the selection, Find the next
  358.         return character, move the insertion point after it, insert "<DD>" at
  359.         the insertion point.
  360.                             
  361. -------------------------------------------------------------------------
  362. •  Copy all lines containing "BBEdit" to the clipboard
  363.  
  364.         !CZ                                    Clear the clipboard
  365.         •!FA"BBEdit" !SL !CT"\s\r"            Find all occurrences of "BBEdit",
  366.                                             Select the line, Copy-append Text containing
  367.                                             the current selection and a carriage return.
  368.                                             
  369. -------------------------------------------------------------------------
  370. •  Copy all lines containing "BBEdit", regarding case, to the
  371. clipboard
  372.  
  373.         !CZ!§k                                Clear the clipboard, set case switch ON
  374.         •!FA"BBEdit" !SL !CT"\s\r"            Find all occurrences of "BBEdit",
  375.                                             Select the line, Copy-append Text containing
  376.                                             the current selection and a carriage return.
  377.                                             
  378. -------------------------------------------------------------------------
  379. •  Compile and Insert a list of all the headings in a document
  380.  
  381.         !CZ!@T
  382.         •!FN"<MENU>"!@S!FS"/MENU>"!FS"\r"!DS
  383.         •!FA"<H#>"!@E!ST!CB!CT"<LI>\t<A HREF=\"#\b\">\b</A>\r"
  384.         •!@T!FN"</H1>"!@E!IS"\r<MENU>\r\c</MENU>"!B3
  385.  
  386.  
  387. -------------------------------------------------------------------------
  388. •  To change the title of your document to word capitalization
  389.  
  390.         !@T !FN"<TITLE>" !FS"</TITLE>" !KW    Move insertion point to the top of the doc.
  391.                                             Find next occurrence of <TITLE>. Extend
  392.                                             selection to "</TITLE>", change case of
  393.                                             selection to Word Capitalization.
  394.  
  395.  
  396.  
  397. (Last updated: Monday, March 6, 1995)
  398.  
  399.  
  400. Lindsay Davies, 
  401. email:    Lindsay.Davies@sheffield.ac.uk
  402.